package com.some;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class BaiDu_12_3_2 {
    public int kList(int[] nums, int k) {
        // 存储奇数
        List<Integer> list1 = new ArrayList<>();
        // 存储偶数
        List<Integer> list2 = new ArrayList<>();
        for (int num : nums) {
            if (num % 2 == 0) {
                list2.add(num);
            } else {
                list1.add(num);
            }
        }
        int size1 = list1.size();
        int size2 = list2.size();
        int sum = 0;
        // 通过排列组合计算出存在多少种情况
        // i代表奇数的个数
        for (int i = 0; i <= k; i += 2) {
            if (size2 >= k - i && size1 >= i) {
                int a = (k - i != 0) ? c(size2, k - i) : 0;
                int b = (i != 0) ? c(size1, i) : 0;
                if (a == 0 || b == 0) {
                    sum += a + b;
                } else if (a == 1 || b == 1) {
                    sum += a + b - 1;
                }
            }
        }
        return sum;
    }

    // C(m,n)
    public int c(int m, int n) {
        //temp 为答案
        int temp = 1;
        //保证n>=m-n
        if (n < m - n)
            return c(m, m - n);
        for (int i = 0; i < m - n; ++i) {
            temp *= n + i + 1;
            temp /= i + 1;
        }
        return temp;
    }
}


class Main_12_3_2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BaiDu_12_3_2 baiDu_12_3_2 = new BaiDu_12_3_2();
        // 输入有多少组测试数据
        int t = sc.nextInt();
        // 结果集和
        int[] res = new int[t];
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            // 单个测试数据
            int[] nums = new int[n];
            for (int j = 0; j < n; j++) {
                nums[j] = sc.nextInt();
            }
            res[i] = baiDu_12_3_2.kList(nums, k);
        }
        for (int re : res) {
            System.out.println(re);
        }
    }
}